package com.bdth.service.impl;

import com.bdth.mapper.DepartmentMapper;
import com.bdth.mapper.PerMapper;
import com.bdth.model.Department;
import com.bdth.model.Per;
import com.bdth.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class DepartmentServiceImpl extends BaseServiceImpl<Department> implements IDepartmentService {

	@Autowired
	private DepartmentMapper mapper;

	@Autowired
	private PerMapper perMapper;

	public List<Department> selectByPId(Object id) throws Exception {
		return mapper.selectByPId(id);
	}

	@Override
	public void add(Department dep) throws Exception {
		super.add(dep);
		Per per = new Per();
		per.setDepid("" + dep.getId());
		per.setNumbers("(0/0/0)");
		per.setNumon("0");
		per.setNumall("0");
		per.setPer("0%");
		perMapper.insertSelective(per);
	}

	@Override
	public List<Map> queryMapDataByMapList(Map map) throws Exception {
		return mapper.queryMapDataByMapList(map);
	}

}
